<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>班级选课</title>
    <%@ include file="/pages/common/head_base.jsp"%>

    <style type="text/css">
        h1 {
            text-align: center;
            margin-top: 200px;
        }

        h1 a {
            color: red;
        }

        input {
            text-align: center;
        }
    </style>

    <script type="text/javascript">
        $(function() {
            //通过Ajax获取所有课程列表并输出
            $.ajax({
                url: "courseServlet?action=findCnoAndCname",
                type: "POST",
                success: function (jsonStr) {
                    // 输出所有的课程列表
                    // jsonStr---json Object
                    eval("var arr = " + jsonStr);
                    // 拼接所有option字符串
                    var str = '<option value="0">---全部---</option>	';
                    for (var i = 0; i < arr.length; i++) {
                        str += '<option value = "'+arr[i].cno+'">' + arr[i].cname + '</option>';
                    }
                    //一次性写到select cno列表中
                    $("#cno").html(str);
                }
            });
        });
    </script>
</head>
<body>

<div id="header">
    <span class="wel_word">班级选课</span>
    <%@ include file="/pages/common/manager_menu.jsp"%>
</div>

<div align="center">

</div>

<div id="main">
    <form action="ccServlet" method="post">
        <input type="hidden" name="action" value="chooseCourse"/>
        <table>
            <tr>
                <td>班级号</td>
                <td>班级名</td>
                <td>课程名</td>
                <td colspan="2">操作</td>
            </tr>
            <tr>
                <td><input name="classno" type="text" value = "${requestScope.clazz.classno}"/></td>
                <td><input name="classname" type="text" value = "${requestScope.clazz.classname}"/></td>
                <td>
                    <select class="select" id="cno" name="cno">

                    </select>
                </td>
                <td><input type="submit" value="提交"/></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </table>
    </form>
</div>

<%@ include file="/pages/common/footer.jsp"%>
</body>
</html>